package com.rent.weixin;

import com.rent.common.utils.IdWorker;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.archaius.ArchaiusAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;

/**
 * @Author zn
 * @Create 2025-03-03 15:59
 * @Version 1.0
 */
// 开启事务
@EnableTransactionManagement
// 开启aop
@EnableAspectJAutoProxy(exposeProxy = true)
// 服务注册
@EnableDiscoveryClient
@ComponentScan(basePackages = {
        "com.database",
        "com.rent"
})
// 不要自动装配数据连接池
@SpringBootApplication(exclude = {DruidDataSourceAutoConfigure.class, ArchaiusAutoConfiguration.class})
public class WeixinApplication {

    public static void main(String[] args) {
        SpringApplication.run(WeixinApplication.class,args);
    }

    // http请求调用Bean
    @Bean(name = "restTemplate")
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    // 自动生成id
    @Bean
    public IdWorker idWorker() {
        return new IdWorker(0, 1);
    }

}
